package com.jing.product.service.impl;

import com.jing.product.domain.dto.PmsProductAttributeCategoryDTO;
import com.jing.product.domain.po.PmsProductAttributeCategoryPO;
import com.jing.product.domain.vo.PmsProductAttributeCategoryVO;
import com.jing.product.mapper.PmsCateoryMapper;
import com.jing.product.service.PmsCategotyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PmsCategotyServiceImpl implements PmsCategotyService {
    @Autowired
    private PmsCateoryMapper pmsCateoryMapper;


    /**
     * 测试商品类型分类分页
     * @return
     */
    @Override
    public List<PmsProductAttributeCategoryVO> page() {
        List<PmsProductAttributeCategoryVO> page = pmsCateoryMapper.page();
        return page;
    }


    @Override
    public void add(PmsProductAttributeCategoryPO productAttributeCategory) {
//        PmsProductAttributeCategoryPO pmsProductAttributeCategoryPo = new PmsProductAttributeCategoryPO();
//        pmsProductAttributeCategoryPo.setName(productAttributeCategory.getName());
        int flag = pmsCateoryMapper.add(productAttributeCategory);
        if(flag<=0){
            throw new RuntimeException("添加失败，请联系管理员");
        }
    }

    @Override
    public void delect(String id) {
        Integer flag = pmsCateoryMapper.delect(id);
        if(flag<=0){
            throw new RuntimeException("删除失败，请联系管理员");
        }
    }

    @Override
    public void update( PmsProductAttributeCategoryDTO productAttributeCategoryDTO) {
        Integer flag = pmsCateoryMapper.update(productAttributeCategoryDTO);
        if(flag<=0){
            throw new RuntimeException("修改失败，请联系管理员");
        }
    }
}
